package org.mat.admin.sys.controller;








import org.mat.admin.sys.controller.page.TableDataInfo;
import org.mat.admin.sys.domain.SysNotice;
import org.mat.admin.sys.service.ISysNoticeService;
import org.mat.admin.sys.util.SecurityUtils;
import org.mat.framework.lang.dto.MatApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公告 信息操作处理
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/notice")
public class SysNoticeController extends BaseController
{
    @Autowired
    private ISysNoticeService noticeService;

    /**
     * 获取通知公告列表
     */

    @GetMapping("/list")
    public TableDataInfo list(SysNotice notice)
    {
        startPage();
        List<SysNotice> list = noticeService.selectNoticeList(notice);
        return getDataTable(list);
    }

    /**
     * 根据通知公告编号获取详细信息
     */

    @GetMapping(value = "/{noticeId}")
    public MatApiResponse getInfo(@PathVariable Long noticeId)
    {
        return MatApiResponse.success(noticeService.selectNoticeById(noticeId));
    }

    /**
     * 新增通知公告
     */

    @PostMapping
    public MatApiResponse add(@Validated @RequestBody SysNotice notice)
    {
        notice.setCreateBy(SecurityUtils.getUsername());
        return toAjax(noticeService.insertNotice(notice));
    }

    /**
     * 修改通知公告
     */

    @PutMapping
    public MatApiResponse edit(@Validated @RequestBody SysNotice notice)
    {
        notice.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(noticeService.updateNotice(notice));
    }

    /**
     * 删除通知公告
     */

    @DeleteMapping("/{noticeIds}")
    public MatApiResponse remove(@PathVariable Long[] noticeIds)
    {
        return toAjax(noticeService.deleteNoticeByIds(noticeIds));
    }
}
